<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="/tld/dictionary" prefix="dictionary"%>
<%@ taglib uri="/tld/flowdictionary" prefix="flowdictionary"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>回款管理</title>
<link rel="stylesheet" href="${ctx}/static/css/style.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/style1.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/kongjian.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/kongjian.css" type="text/css" /> 
<link rel="stylesheet" href="${ctx}/static/css/jquery.ui.all.css" type="text/css"/>
<link rel="stylesheet" href="${ctx}/static/css/thickbox.css" type="text/css"/>
<script src="${ctx}/static/script/jquery-1.4.min.js" type="text/javascript"></script>
<script src="${ctx}/static/script/jquery.ui.core.js" type="text/javascript"></script>
<script src="${ctx}/static/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script src="${ctx}/static/script/js_validator.js" type="text/javascript"></script>
<script src="${ctx}/static/script/thickbox.js" type="text/javascript"></script>
<script src="${ctx}/static/script/jsCoreUtil.js" type="text/javascript"></script>
</head>

<body>
<form:form id="mainForm" action="${ctx}/backsection/backsection_list" modelAttribute="backSectionForm" method="post" onsubmit="doSubmit()">
<div class="er_banner">回款管理 </div>
<br/>
	<div>
		<p style=" text-align:left; height:30px; margin:0 20px; padding:0 10px; line-height:30px; border:#3b97e4 solid 1px;">
		预计回款总金额：<fmt:formatNumber value="${backSectionForm.returnAllAmt}" pattern="##,###.##" /> 元  &nbsp;
		预计回收总金额：<fmt:formatNumber value="${backSectionForm.returnRecAllAmt}" pattern="##,###.##" /> 元 &nbsp; 
		预计回款再投资总金额：<fmt:formatNumber value="${backSectionForm.returnInvestAllAmt}" pattern="##,###.##" /> 元&nbsp; 
		预计回款再定投投资总金额：<fmt:formatNumber value="${backSectionForm.regularAllAmt}" pattern="##,###.##" /> 元
		</p>
    </div>
  <div class="shenqing2">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="81">客户编号：</td>
            <td width="130px" style="color:#2E74D1;"><input type="text" name="investInfo.customerInfo.customerCode" id="customerCode" value="${backSectionForm.investInfo.customerInfo.customerCode}" class="ggkj_inputtext_80"/></td>
            <td width="85">客户姓名：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text" name="investInfo.customerInfo.cnName" id="cnName" value="${backSectionForm.investInfo.customerInfo.cnName}" class="ggkj_inputtext_80"/>
            </td>
			<td width="85">投资编号：</td>
            <td width="150px" style="color:#2E74D1;"><input type="text" name="investInfo.id" id="investId" value="${backSectionForm.investInfo.id}" class="ggkj_inputtext_80"/>
            </td>
			<td width="85">实际投资日期：</td>
            <td width="250px" style="color:#2E74D1;">
             <input type="text" id="investStartDate" name="investInfo.investStartDate" value="<fmt:formatDate value='${backSectionForm.investInfo.investStartDate}'   pattern='yyyy-MM-dd' type='date' dateStyle='long' />" size="10" onClick="WdatePicker()" readonly="true"/>-
            <input type="text" id="investEndDate" name="investInfo.investEndDate" value="<fmt:formatDate value='${backSectionForm.investInfo.investEndDate}'   pattern='yyyy-MM-dd' type='date' dateStyle='long' />" size="10" onClick="WdatePicker()" readonly="true"/>
            </td>
            <td width="85">债权还款日：</td>
            <td width="150px" style="color:#2E74D1;">
            	<form:select path="returnDateQuery">
            	<option value="" selected>请选择</option>
            	<option value="01" <c:if test="${backSectionForm.returnDateQuery=='01'}">selected</c:if> >1日</option>
            	<option value="16" <c:if test="${backSectionForm.returnDateQuery=='16'}">selected</c:if> >16日</option>
            	</form:select>
            </td>
            <td width="85">投资状态：</td>
            <td width="150px" style="color:#2E74D1;">
            	<form:select path="investInfo.flowId">
            	<option value="">请选择</option>
            	<flowdictionary:options type="0200" selectedValue="${backSectionForm.investInfo.flowId}"/>
            </form:select>
            <script>
            function removeSelectItem(flowIds){
	 			for(var i=0;i<flowIds.options.length;i++){
            		if(flowIds.options[i].value!=""){
            			if(flowIds.options[i].value<"02000008"||flowIds.options[i].value=="02000011"||flowIds.options[i].value=="02000012"){
            				flowIds.options.remove(i);
            				removeSelectItem(flowIds);
            			}
            		}
            	
            	}
 			}
 			function selectItemChecked(flowIds,pval){
 				for(var i=0;i<flowIds.options.length;i++){
            			if(flowIds.options[i].value==pval){
            				flowIds.options[i].selected=true;
            			}
            	
            	}
 			}
            var flowIds=document.getElementById("investInfo.flowId");
            var pval=flowIds.options[flowIds.selectedIndex].value;
            removeSelectItem(flowIds);
            selectItemChecked(flowIds,pval)
            </script>
            </td>
			 <td width="93"><input name="Input" type="submit" class="chaxun_btn" value="&nbsp;&nbsp;查询" />
             </td>
          </tr>
      </table>
    </div>
<div class="yiban">
	<table style="width:100%;" class="ggkj_table"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th scope="col">投资编号</th>
    <th scope="col">客户编号</th>
    <th scope="col">客户姓名</th>
    <th scope="col">债权还款日</th>
    <th scope="col">回款金额</th>
    <th scope="col">预计回收金额</th>
    <th scope="col">回款应付金额</th>
    <th scope="col">回款账户管理费</th>
    <th scope="col">月定投金额</th>
    <th scope="col">实际投资日期</th>
    <th scope="col">理财产品</th>
    <th scope="col">状态</th>
    <th scope="col">操作</th>
  </tr>
	<c:forEach items="${page.result}" var="item" varStatus="stauts">
			<c:choose>
  			<c:when test="${stauts.count%2==0}">
  				<tr class="ggkj_tdColr">
  			</c:when>
  			<c:otherwise>
  				<tr >
  			</c:otherwise>
		</c:choose>
	<td>${item.investInfo.id}</td>
    <td height="34">${item.investInfo.customerInfo.customerCode}</td>
    <td>${item.investInfo.customerInfo.cnName}</td>
    <td><dictionary:display code="${item.investInfo.loanReturnDate}"/></td>
    <td><fmt:formatNumber value="${item.returnAmt}" pattern="##,###.##"/></td>
    <td><fmt:formatNumber value="${item.retuenBackAmt}" pattern="##,###.##"/></td>
    <td><fmt:formatNumber value="${item.payAmt}" pattern="##,###.##"/></td>
    <td><fmt:formatNumber value="${item.accountManageFee}" pattern="##,###.##"/></td>
    <td >
	    <c:if test="${item.investInfo.regularType=='00130001'}">
			<div align="center">--</div>
		</c:if>
		<c:if test="${item.investInfo.regularType=='00130002'}">
			<div align="center">
			<fmt:formatNumber value="${item.investInfo.regularAmt}"  pattern="##,###.##"/>
			</div>
		</c:if>	
    </td>
    <td>
    <c:if test="${item.investInfo.regularType=='00130002'}"><!-- 定投 -->
		<fmt:formatDate value="${item.investInfo.regularStartDate}"   pattern="yyyy-MM-dd" type="date" dateStyle="long" />
	</c:if>
	<c:if test="${item.investInfo.regularType=='00130001'}"><!-- 非定投 -->
		<fmt:formatDate value="${item.investInfo.investStartDate}"   pattern="yyyy-MM-dd" type="date" dateStyle="long" />
	</c:if>
    </td>
    <td><dictionary:display code="${item.investInfo.productType}"/></td>
    <td><flowdictionary:display code="${item.investInfo.flowId}"/></td>
    <td>
   <c:choose>
		<c:when test="${item.investInfo.flowId=='02000010' || item.investInfo.flowId=='02000011' || item.investInfo.flowId=='02000008'}">
			回款撮合
		    | 
		    定投撮合
		</c:when>
		<c:when test="${item.investInfo.flowId=='02000014'}">
		    <a href="#" id="transRecommend" name="transRecommend" onClick="recommend('<fmt:formatDate value="${item.returnDate}"  pattern="yyyy-MM-dd" type="date" dateStyle="long" />','${item.id}','03');">回款撮合</a>
		    | 
		    定投撮合
		</c:when>
		<c:when test="${item.investInfo.flowId=='02000013'}">
			<c:if test="${item.investInfo.regularType=='00130001'}">
			回款撮合
		    | 
		    定投撮合
			</c:if>
			<c:if test="${item.investInfo.regularType=='00130002'}">
			回款撮合
		    | 
		    <a href="#" id="transRecommend" name="transRecommend" onClick="recommend('<fmt:formatDate value="${item.returnDate}"  pattern="yyyy-MM-dd" type="date" dateStyle="long" />','${item.id}','01');">定投撮合</a>
			</c:if>
		</c:when>
		<c:when test="${item.investInfo.flowId=='02000009'}">
			<c:if test="${item.investInfo.regularType=='00130001'}">
			<a href="#" id="transRecommend" name="transRecommend" onClick="recommend('<fmt:formatDate value="${item.returnDate}"  pattern="yyyy-MM-dd" type="date" dateStyle="long" />','${item.id}','03');">回款撮合</a>
		    | 
		    定投撮合
			</c:if>
			<c:if test="${item.investInfo.regularType=='00130002'}">
			<a href="#" id="transRecommend" name="transRecommend" onClick="recommend('<fmt:formatDate value="${item.returnDate}"  pattern="yyyy-MM-dd" type="date" dateStyle="long" />','${item.id}','03');">回款撮合</a>
		    | 
		    <a href="#" id="transRecommend" name="transRecommend" onClick="recommend('<fmt:formatDate value="${item.returnDate}"  pattern="yyyy-MM-dd" type="date" dateStyle="long" />','${item.id}','01');">定投撮合</a>
			</c:if>
		</c:when>
	</c:choose> 
    </td>
  </tr>
	</c:forEach>
</table>
	
</div>
<div class="ggkj_pagecontainer">
  <div class="ggkj_pageBGleft">
    	<span class="ggkj_pageBGright"></span>
    	<a href="javascript:jumpPage(1)" class="ggkj_pageUpa">
        
        </a>
        <a href="javascript:jumpPage(${page.prePage})" class="ggkj_pageUp">
        
        </a>
        <span class="ggkj_insertline"></span>
        <span class="ggkj_pageSpan">
        	页<input type="text" id="pageNo" name="pageNo" class="ggkj_inputtext_30" value="${page.pageNo}">OF ${page.totalPages}
        </span>
        <span class="ggkj_insertline"></span>
        <a href="javascript:jumpPage(${page.nextPage})" class="ggkj_pageDown">
        
        </a>
        <a href="javascript:jumpPage(${page.totalPages})" class="ggkj_pageDowna">
        
        </a>
        <span class="ggkj_insertline"></span>
        
    </div>
</div>
<div style="display:none">
	<div id="showbox" style="width:100px; height:100px;" class="yiban">
		<table width="100%" align="center"  cellspacing="0" cellpadding="0"  class="ggkj_table">
		<tr>
		  <TD colspan="2" class="er_banner"><span class="STYLE2">交易撮合</span> </TD>
		</tr>
		<tr><td colspan="3"></td></tr>
		<tr ><TD > 约定交割日期</TD>
		<td ><input type="text" id="return_Date" name="return_Date" tabindex="0" title="" value="" maxlength="10" size="12" readonly="true" /></td>
		</tr>
		<tr><td colspan="3"></td></tr>
		<tr>
		<td colspan="3" >
		<input type="button" value="&nbsp;&nbsp;&nbsp;&nbsp;查找债权"  class="tijiao_big" onClick="OpenMatchWindow();"/>&nbsp;&nbsp;&nbsp;<input type="button" value="&nbsp;&nbsp;&nbsp;&nbsp;返回" onClick="tb_remove();" class="quxiao_big"/>
		</td>
		</tr>
		</table>
		<hr   color="#FFFFFF"/>
	</div>
</div>

</form:form>
<form:form id="backSectionForm" action="${ctx}/backsection/backsection_add" modelAttribute="backSectionForm" method="post">
	<input id="id" type="hidden" name="id" value="" />
	<input id="returnDate" type="hidden" name="returnDate" value="" />
	<input id="payType" type="hidden" name="payType" value="" />
</form:form>
</body>
<script>
function jumpPage(pageNo) {
	document.getElementById('pageNo').value=pageNo;
	document.getElementById('mainForm').submit();
}

function _submit(id,action){
	var thisform = document.getElementById('mainForm');
	thisform.action =action;
	thisform.submit();
}
function recommend(deliveryDate,returnId,payType){
	var thisform = document.getElementById('backSectionForm');
 	thisform.returnDate.value=deliveryDate;
 	document.getElementById('return_Date').value = deliveryDate;
 	thisform.id.value=returnId;
 	
 	SetValue('payType',payType);
 	SetValue('returnDate',deliveryDate);
 	SetValue('id',returnId);
 	
	tb_show('','#TB_inline?height=150&amp;width=250&amp;inlineId=showbox&amp;modal=true','');
}

function OpenMatchWindow()
{		
 	var thisform = document.getElementById('backSectionForm');
 	//thisform.action = '${ctx}/backsection/backsection_main';
 	thisform.action = '${ctx}/backsection/backsection_add';
 	thisform.submit();
}
function doSubmit(){
	document.getElementById('pageNo').value='1';
}
</script>
</html>
